package com.geek.boot.config;

import com.geek.boot.entity.Car;
import com.geek.boot.entity.Person;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenmin
 * @desc TODO
 * @date 2025/7/14
 *
 * 注解 @Conditional条件装配
 * 1.@ConditionalOnBean
 * 2.@ConditionalOnMissingBean
 * 3.@ConditionalOnClass
 * 4.@ConditionalOnMissingClass
 * 5.@ConditionalOnWebApplication
 *
 * SpringBoot定制化思路之一
 */
//生效条件：若没有指定的bean则生效
//@ConditionalOnMissingBean(Person.class)
@Configuration
public class MyConfig3 {

    //生效条件：若找到Car类则生效
    @ConditionalOnClass(Car.class)
    @Bean
    public Car c1(){
        return new Car("Model Y" , 3500000);
    }

}
